package com.example.administrator.szb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.szb.R;
import com.example.administrator.szb.bean.ProjectDetail;

import java.util.List;


/**
 * Created by stone on 2018/1/5.
 */

public class ProDeatilJGAdapter extends android.widget.BaseAdapter {
    private List list;

    private Context context;
    LayoutInflater inflater;
    public ProDeatilJGAdapter(List list, Context context) {
        this.list = list;
        this.context = context;
        inflater  = LayoutInflater.from(this.context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ProjectDetail.ServiceCounBean getItem(int position) {
        return (ProjectDetail.ServiceCounBean)list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView = inflater.inflate(R.layout.item_jgs,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        Glide.with(context).load(getItem(position).getZhenshi_img()).error(R.mipmap.default_header_s).into(holder.image);
        holder.name.setText(getItem(position).getCompany()+"-"+getItem(position).getName());
        holder.address.setText(getItem(position).getCity());
        holder.status.setText(getItem(position).getStatus());
        return convertView;
    }

    class ViewHolder{
         com.makeramen.roundedimageview.RoundedImageView image;
         TextView name;
         TextView address;
         TextView status;
        public ViewHolder(View view){
            image = (com.makeramen.roundedimageview.RoundedImageView) view.findViewById(R.id.image);
            name = (TextView) view.findViewById(R.id.name);
            address = (TextView) view.findViewById(R.id.address);
            status = (TextView) view.findViewById(R.id.status);
        }
    }
}
